package com.chis.client;

import java.util.Arrays;
import java.util.Map;

public class CheckSignUtil {

    public static String signToRequest(Map<String, Object> params, String secret, String signMethod) throws Exception {
        StringBuilder query = new StringBuilder();
        String[] keys = params.keySet().toArray(new String[0]);
        Arrays.sort(keys);
        for( String key: keys){
            Object value = params.get( key);
            query.append( key).append("=").append( value).append("&");
        }
        query.deleteCharAt( query.length()-1);
        query.append( secret);
        return SignUtil.createHashSign( signMethod, query.toString().getBytes("utf-8"));
    }
}
